<template>
  <div>
    <el-dialog
      :title="titleType"
      width="1200px"
      :visible.sync="dialogVisible"
      :before-close="handleClose"
      :close-on-click-modal="false"

    >
      <div class="dialogBody">
        <div class="shoInfo">
          <ul>
            <li>
              <div>
                <span class="item_lable">微项目名称：</span>
                {{ info.project_name }}
              </div>
            </li>
            <li class="flexItem">
              <div class="ellipsis" :title="info.project_content">
                <span class="item_lable">项目内容：</span>
                {{ info.project_content }}
              </div>
              <div>
                <span class="item_lable">申请条件：</span>
                {{ info.project_apply_content }}
              </div>
            </li>
            <li class="flexItem">
              <div>
                <span class="item_lable">积分数量：</span>
                {{ info.point_num }}
              </div>
              <div>
                <span class="item_lable">发布人：</span>
                {{ info.publisher }}
              </div>
            </li>
            <li>
              <div>
                <span class="item_lable">发布时间：</span>
                {{ info.create_time }}
              </div>
            </li>
          </ul>
        </div>
        <div class="tablesCard bgfff">
          <div class="tablesCardTop">
            <div class="totalTxt">申请列表（{{ info.comments.length }}）</div>
          </div>
          <el-table
            :data="info.comments"
            border
            size="small"
            height="454"
            style="width: 100%"
          >
            <el-table-column
              prop="time"
              label="选择"
              align="center"
              width="80"
              v-if="info.status == 1"
            >
              <template slot-scope="scope">
                <el-radio
                  :label="scope.$index"
                  v-model="radio"
                  @change.native="getCurrentRow(scope.row)"
                  >&nbsp;</el-radio
                >
              </template>
            </el-table-column>
            <el-table-column prop="userName" label="申请人姓名" align="center">
            </el-table-column>
            <el-table-column prop="mobile" label="手机号" align="center" />
            <el-table-column prop="" label="达人技能" align="center">
              <template slot-scope="scope">
                <span v-for="(item, index) in scope.row.talent" :key="index">
                  {{ item.type_name }}、
                </span>
              </template>
            </el-table-column>
            <el-table-column prop="content" label="申请说明" align="center" />
            <el-table-column prop="" label="图片" align="center">
              <template slot-scope="scope">
                <img
                  v-if="scope.row.pic"
                  style="object-fit: contain"
                  width="60"
                  height="60"
                  :src="$resDomain + scope.row.pic"
                  alt=""
                />
              </template>
            </el-table-column>
            <el-table-column prop="create_at" label="申请时间" align="center" />
            <el-table-column
              prop=""
              label="同意时间"
              align="center"
              v-if="info.status == 2"
            >
              <template slot-scope="scope">
                <span v-if="info.distribution_person_id == scope.row.uid">{{
                  info.handle_time
                }}</span>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" v-if="info.status == 1">
        <el-button size="small" @click="handleClose">取 消</el-button>
        <el-button size="small" type="primary" @click="onSubmit()"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { minProjectDetail, AuditingMinProject } from "@/api/miniApply.js";
export default {
  name: "",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    projectId: {
      type: Number,
      default: null,
    },
  },
  data() {
    return {
      titleType: "查看",
      info: {
        comments: [],
      },
      tableData: [],
      radio: "",
      params: {
        id: "",
      },
      total: 100,
    };
  },

  components: {},

  computed: {},

  beforeMount() {},

  mounted() {
    this.getDetail();
  },

  methods: {
    getDetail() {
      minProjectDetail({
        id: this.projectId,
      }).then((res) => {
        if (res.code == 200) {
          console.log(res.data, "000099999999---");
          this.info = res.data[0];
          this.params.id = this.info.id;
          if (res.data[0].status == 1) {
            this.titleType = "审核";
          } else {
            this.titleType = "查看";
          }
        }
      });
    },
    getCurrentRow(val) {
      this.params.userId = val.uid;
    },
    onSubmit() {
      if (this.radio === "") {
        this.$message({
          type: "warning",
          message: "请选择申请人",
        });
        return false;
      }
      AuditingMinProject(this.params).then((res) => {
        if (res.code == 200) {
          this.$message({
            type: "success",
            message: res.msg,
          });
          this.$emit("handleClose", true);
        }
      });
    },
    handleClose() {
      this.$emit("handleClose");
    },
  },

  watch: {},
};
</script>
<style lang="scss" scoped>
.dialogBody {
  .shoInfo {
    margin-bottom: 40px;
    ul {
      color: #222;
      li {
        margin-bottom: 10px;
        .item_lable {
          text-align: right;
          display: inline-block;
          width: 100px;
          color: #606266;
        }
      }
      .flexItem {
        display: flex;
        > div {
          flex: 1;
        }
      }
    }
  }
  .tablesCard {
    padding: 0;
    // .totalTxt {
    //   padding-left: 8px;
    //   position: relative;
    //   &::after {
    //     position: absolute;
    //     left: 0px;
    //     top: 5px;
    //     content: "";
    //     width: 2px;
    //     height: 12px;
    //     background: #1890ff;
    //   }
    // }
  }
}
</style>
